<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*,java.io.*,java.sql.*,InvestmentPojo.*,ImmovableIndia.*;"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Foreign Exchange Calculator</title>

</head>
<%!
	ConnectionPool pool=null;
	public Connection getConnection() throws SQLException, Exception {
		pool=new ConnectionPool();
		return pool.getConnection();
	}
	%>
<% 
List optionsList123=new ArrayList();
Connection con=null;
Statement st=null;
ResultSet rs=null;
String optionvalue="";
try{
	con=getConnection();
	st=con.createStatement();
	rs=st.executeQuery("select * from investment_in_india where form_id = 4 order by option_label");
	while(rs.next()){
		OptionsList obj = new OptionsList();
		obj.setOptionId(rs.getString(1));
		obj.setListTypeId(rs.getString(2));
		obj.setOptionLabel(rs.getString(3));
		obj.setOptionValue(rs.getString(4));
		obj.setQestFlag(rs.getString(7));
		obj.setShowFlag(rs.getString(8));
		optionsList123.add(obj);
	}
}catch(Exception e ){
	e.printStackTrace();
}finally{
	try {
		if(null != rs)
			pool.releaseResources(rs);
		System.out.println("Connection RS closed........--------------");
		if(null != st)
			pool.releaseResources(st);
		System.out.println("Connection ST closed........--------------");
		if(null != con)
		pool.releaseConnection(con);
		System.out.println("Connection con closed........--------------");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
%>

<script>
function loadSectorDropDown()
{
	var selectedValue ='';
	var selectedInvestor ='';
	var radios ='';
	
	radios = document.getElementsByName("entity");		
	for(var i = 0; i < radios.length; i++) {
	    if(radios[i].checked) selectedValue = radios[i].value;  
	} 	
	radios = document.getElementsByName("investor");
	for(var i = 0; i < radios.length; i++) {
	    if(radios[i].checked) selectedInvestor = radios[i].value;  
	}
	//alert("selected value..."+selectedValue);
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {
		// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	  }
	else
	  {
		// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	     {
		  document.getElementById("TR04").innerHTML = "";
	     document.getElementById("TR04").innerHTML= xmlhttp.responseText;
 	    }
	  }
	xmlhttp.open("GET","dropDownAction.do?key="+selectedValue+"&invkey="+selectedInvestor,true);
	xmlhttp.send();
	selectedValue = '';
}
function loadFormToSubmit()
{

	var selectedValue ='';
	var sectorId = '';
	var subsectorId = '';
	var invRadiosValue = getSelectedRadiosValue("exchange");
	    if(invRadiosValue != "" && null != invRadiosValue){ 
	    	selectedValue = invRadiosValue;  
	}	
	//alert("selected value = "+selectedValue);
	//document.getElementById("selected").innerHTML = "Selected Key - "+selectedValue;
	var xmlhttp;
	if (window.XMLHttpRequest)
	  {
		// code for IE7+, Firefox, Chrome, Opera, Safari
	   xmlhttp=new XMLHttpRequest();
	  }
	else
	  {
		// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	     {
		document.getElementById("myDiv").innerHTML='';
		cache: false;
	    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
	    cache: false;
	    }
	  }
	xmlhttp.open("GET","investorAction.do?key="+selectedValue+"&formId="+4,true);
	xmlhttp.send();
	selectedValue = '';
}
function radioUncheckFun(radiosname){
	//document.getElementById("selected").style.display="none";
	var radList = document.getElementsByName(radiosname);
	if(null != radList){
	 for (var i = 0; i < radList.length; i++) {
	 if(radList[i].checked) radList[i].checked = false;
	 }
}}
function getSelectedRadiosValue(NameofRadios){
	//document.getElementById("selected").style.display="none";
	var selectedRadioValue='';
	var radList = document.getElementsByName(NameofRadios);
	if(null != radList){
	 for (var i = 0; i < radList.length; i++) {
	 if(radList[i].checked) selectedRadioValue = radList[i].value;
	 }
	 return selectedRadioValue;
   }
}
function goForConclution(){
	loadFormToSubmit();
	document.getElementById("Answers").style.display="";
	//document.getElementById("selected").style.display="";
	document.getElementById("myDiv").innerHTML="<img alt='Plz wait...' src='loading9.gif' width='30'/>&nbsp;&nbsp;Plz wait...while loading...";
	goForGuidelines();
}
function setVisibilityArr(varArray,visibility){
    if(null != varArray){
        for(i = 0; i < varArray.length; i++){
            var tdvar = varArray[i];
            if(tdvar != null){
            tdvar.style.display=visibility;
            }
        }
    }
 }

function onClickForeignExe(){
	//document.getElementById("selected").style.display="none";
	var selectedRadioValue='';
	
	document.getElementById("Answers").style.display="none";
	var radList = document.getElementsByName("exchange");
	if(null != radList){
		 for (var i = 0; i < radList.length; i++) {
		 if(radList[i].checked) selectedRadioValue = radList[i].value;
		 }
		   <% if(optionsList123 != null){
	for(int i=0;i<optionsList123.size();i++){
	OptionsList obj1 =(OptionsList)optionsList123.get(i); 
	if(obj1.getListTypeId() != null && obj1.getListTypeId().equals("10") && obj1.getShowFlag().equals("Y")){
		String abc = (String)obj1.getOptionValue();
		%>
		if(selectedRadioValue == '<%=abc%>'){
			document.getElementById('litag'+selectedRadioValue).style.display="";
			document.getElementById('quest').style.display="";
			document.getElementById('submitbutton').style.display="";
		}else{
			document.getElementById('litag<%=abc%>').style.display="none";
		}
		<%
			}
		}
	}
	%>
	
	   }
}

function onClickToShow(){
	//document.getElementById("selected").style.display="none";
	radioUncheckFun("exchange");
	document.getElementById('quest').style.display="none";
	document.getElementById('submitbutton').style.display="none";
	document.getElementById("Answers").style.display="none";
	for(var i=1;i<35;i++){
		document.getElementById('litag'+i).style.display="";
		continue;
	}
}
function goForGuidelines(){
	 wLeft = window.screenLeft ? window.screenLeft : window.screenX;
   wTop = window.screenTop ? window.screenTop : window.screenY;
	 w=610; h=320;
  var left = wLeft + (window.innerWidth / 2) - (w / 2);
  var top = wTop + (window.innerHeight / 2) - (h / 2);
  var settings='toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left;
  var URL="dropDownAction.do?formGuideId=FOREIGN-EXCHANGE-TOOL.GuideInfo&method=FormGuidsInfo";
	window.target='target';
  myWind=window.open(URL,'target',settings);
	//myWind.document.write("Guidelines Test Success...!");
	myWind.focus();
	
}
</script>

<body bgcolor="">
	<form name="frm" method="post">
		<table width="730" align="center" border="0" cellspacing="0"
			cellpadding="3" valign="middle">
			<input type="hidden" name="formId" value="4" />
			<tr>
				<td>&nbsp;</td>
			</tr>
		</table>
		<table width="730" align="center" class="TBFORM" border="0"
			cellspacing="0" cellpadding="0" valign="middle">

			<tr>
				<td align="center" height="10" class="TITLEFORM">Foreign Exchange
					Tool</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td width="730" style="padding-left:10px">
					<table width="700" align="center" class="TDBBLRFORM" border="0"
						cellspacing="0" cellpadding="3">
						<tr>
							<td colspan="2" class="testform" width="705" id=""><b>Purpose
									of drawal of Foreign Exchange</b> &nbsp;<a class="anchor" style="display: none;"
								id="quest" href="javascript:onClickToShow()" value="show all"
								align="right">show all</a></td>
						</tr>
					</table>
					<table width="710" align="center" class="TDBBLRFORM" border="0"
						cellspacing="0" cellpadding="3">

						<% if(optionsList123 != null){
	
	//System.out.print(optionsList123.size());
	for(int i=0;i<optionsList123.size();i++){
		
	OptionsList obj =(OptionsList)optionsList123.get(i); 
	if(obj.getListTypeId() != null && obj.getListTypeId().equals("10") && obj.getShowFlag().equals("Y")){
		//System.out.println("============================"+i);
	%>
						<tr id="litag<%=obj.getOptionValue()%>">
							<td width="20" valign="top" class="PH2"><input type="radio"
								name="exchange" id="<%=obj.getOptionId()%>"
								value="<%= obj.getOptionValue()%>" onclick="onClickForeignExe()" /></td>
							<td width="680" valign="top" class="PH4"><font><label
										for="<%=obj.getOptionId()%>"><%= obj.getOptionLabel()%></label></font></td>
						</tr>
						<%	
	//System.out.println(obj.getListTypeId()+"  treeeeeeeeeeeeeeeeeeeeeeeee   "+obj.getOptionLabel()+"  " );
	}
	}	  		
	
} %>
					</table>

					<div id="submitbutton" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
							<tr align="center">
								<td><a class="anchor" align="center" id="finalanswer"
									href="javascript:goForConclution()" value="">Go For
										Conclusion</a></td>
							</tr>
							<!-- <tr>
								<td id="selected" style="display: none;"></td>
							</tr> -->
						</table>
					</div>
					</div>
					<div id="Answers" style="display: none;">
						<table width="700" align="center" border="0" cellspacing="0"
							cellpadding="0" valign="middle">
							<tr>
								<td>&nbsp;</td>
							</tr>
						</table>

						<table width="700" align="center" class="TBFORM" border="0"
							cellspacing="0" cellpadding="0" valign="middle">
							<tr>
								<td class="testform" width="705" callspan="1" align="left"><font size="2"><b>Know Eligibility with Allied Conditions</b></font></td>
							</tr>
							<tr>
								<td id="myDiv" align="center"></td>
							</tr>
						</table>
						<table width="700" align="center" border="0" cellspacing="0"
								cellpadding="0" valign="middle">
								<tr>
									<td>&nbsp;</td>
								</tr>
							</table>
							<table width="700" align="center" border="0" cellspacing="0"
								cellpadding="0" valign="middle">
								<tr>
									<td><a class="anchor" style="width:170px;" id="finalanswer"
									href="javascript:goForGuidelines()" value=""><b>General
										Guidelines</b></a></td>
								</tr>
							</table>
					</div>
			<tr>
				<td>&nbsp;</td>
			</tr>
			</td>
			</tr>
		</table>
		<table width="700" align="center" border="0" cellspacing="0"
			cellpadding="0" valign="middle">
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
			</tr>
		</table>

	</form>
</body>
<script type="text/javascript">
radioUncheckFun("exchange");
</script>
</html>